package com.flbill.mapper;

import com.flbill.pojo.entity.SignIn;
import com.flbill.pojo.entity.User;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface UserMapper {
    
    @Select("SELECT * FROM user WHERE username = #{username}")
    User findByUsername(String username);

    @Insert("INSERT INTO user (username, password, phone_number, fixed_income, expected_expense, create_time, update_time, status) " +
            "VALUES (#{username}, #{password}, #{phoneNumber}, #{fixedIncome}, #{expectedExpense}, #{createTime}, #{updateTime}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(User user);

    @Select("SELECT * FROM user WHERE id = #{id}")
    User selectById(Integer id);

    @Select("select user.expected_expense from user where id = #{userId}")
    Float PlanExpensePie(Integer userId);

    @Select("select user.fixed_income from user where id = #{userId}")
    Float getFixedIncome(Integer userId);
    

    Long countUsers(String username);
    

    List<User> pageQuery(String username, int offset, int pageSize);

    @Delete("DELETE FROM user WHERE id = #{id}")
    void deleteUser(Integer id);

    @Select("SELECT * FROM user WHERE id = #{id}")
    User getUserById(Integer id);

    @Update("UPDATE user SET status = #{status} WHERE id = #{id}")
    void updateStatus(Integer id, Integer status);
}